The number of cylinders for this disk is set to 7533. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m Command Action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Command (m for help): d Selected partition 1
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-7533, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-7533, default 7533): Using default value 7533
Command (m for help): p
Disk /dev/sda: 8100 MB, 8100249600 bytes 175 heads, 12 sectors/track, 7533 cylinders Units = cylinders of 2100 * 512 = 1075200 bytes
Device Boot Start End Blocks Id System /dev/sda1 1 7533 7908626 83 Linux
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table
检查分区以查看是否已创建。
1 2 3 4 5 6 7 8
fdisk -lu /dev/sda
Disk /dev/sda: 8100 MB, 8100249600 bytes 175 heads, 12 sectors/track, 7533 cylinders, total 15820800 sectors Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System /dev/sda1 2048 15819299 7908626 83 Linux
mkfs.ext4 -m 0 -L Main /dev/sda1 mke2fs 1.42.8 (20-Jun-2013) Filesystem label=Main OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 7808 inodes, 1977156 blocks 0 blocks (0.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2025848832 61 block groups 32768 blocks per group, 32768 fragments per group 128 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
注意:如果格式化容量超过256 TB的USB驱动器,则可以使用命令mkfs.ext4 -m 0 -T largefile -L Main /dev/sda1
注意:超级用户使用了5%的磁盘容量。
拔下磁盘,然后再次插入以创建以下目录,或者使用下面的这两个命令。
1 2
mkdir /media/Main mount -t ext4 /dev/sda1 /media/Main
Command (m for help): m Command Action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Command (m for help): d Selected partition 1
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-15820799, default 2048): Using default value 2048 Last sector or +size or +sizeM or +sizeK (2048-15820799, default 15820799): +256M
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First sector (502049-15820799, default 502049): Using default value 502049 Last sector or +size or +sizeM or +sizeK (502049-15820799, default 15820799): Using default value 15820799
Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 82 Changed system type of partition 1 to 82 (Linux swap)
Command (m for help): p
Disk /dev/sda: 8100 MB, 8100249600 bytes 175 heads, 12 sectors/track, 7533 cylinders, total 15820800 sectors Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System /dev/sda1 2048 502048 250000+ 82 Linux swap Partition 1 does not end on cylinder boundary /dev/sda2 502049 15820799 7659375+ 83 Linux Partition 2 does not end on cylinder boundary
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table
mkfs.ext4 -m 0 -L Main /dev/sda2 mke2fs 1.42.8 (20-Jun-2013) Filesystem label=Main OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 7552 inodes, 1914843 blocks 0 blocks (0.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1962934272 59 block groups 32768 blocks per group, 32768 fragments per group 128 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
注意:如果格式化容量超过256TB 的USB驱动器,则可以使用命令mkfs.ext4 -m 0 -T largefile -L Main /dev/sda1
并创建交换空间:
1 2
mkswap /dev/sda1 Setting up swapspace version 1, size = 255996416 bytes
mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro,relatime) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) usbfs on /proc/bus/usb type usbfs (rw,relatime) tmpfs on /dev type tmpfs (rw,relatime,size=8k) tmpfs on /etc type tmpfs (rw,noatime,size=2048k) tmpfs on /home type tmpfs (rw,relatime,size=1024k) tmpfs on /media type tmpfs (rw,relatime,size=8k) tmpfs on /mnt type tmpfs (rw,relatime,size=8k) tmpfs on /tmp type tmpfs (rw,relatime,size=24576k) tmpfs on /var type tmpfs (rw,relatime,size=4096k) devpts on /dev/pts type devpts (rw,relatime,mode=600) /dev/sda1 on /media/Main type ext4 (rw,noatime,data=ordered)
mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro,relatime) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) usbfs on /proc/bus/usb type usbfs (rw,relatime) tmpfs on /dev type tmpfs (rw,relatime,size=8k) tmpfs on /etc type tmpfs (rw,noatime,size=2048k) tmpfs on /home type tmpfs (rw,relatime,size=1024k) tmpfs on /media type tmpfs (rw,relatime,size=8k) tmpfs on /mnt type tmpfs (rw,relatime,size=8k) tmpfs on /tmp type tmpfs (rw,relatime,size=24576k) tmpfs on /var type tmpfs (rw,relatime,size=4096k) devpts on /dev/pts type devpts (rw,relatime,mode=600) /dev/sda1 on /media/Main type ext4 (rw,noatime,data=ordered) /dev/sda1 on /opt type ext4 (rw,noatime,data=ordered)
如您所见,/ dev / sda1分区已安装到/ media / Main,下一行显示/ media / Main / opt已安装到/ opt。
同样,如果您有交换分区/ dev / sda1,您将看到另一个输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro,relatime) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) usbfs on /proc/bus/usb type usbfs (rw,relatime) tmpfs on /dev type tmpfs (rw,relatime,size=8k) tmpfs on /etc type tmpfs (rw,noatime,size=2048k) tmpfs on /home type tmpfs (rw,relatime,size=1024k) tmpfs on /media type tmpfs (rw,relatime,size=8k) tmpfs on /mnt type tmpfs (rw,relatime,size=8k) tmpfs on /tmp type tmpfs (rw,relatime,size=24576k) tmpfs on /var type tmpfs (rw,relatime,size=4096k) devpts on /dev/pts type devpts (rw,relatime,mode=600) /dev/sda2 on /media/Main type ext4 (rw,noatime,data=ordered) /dev/sda2 on /opt type ext4 (rw,noatime,data=ordered)