UNIX System Administration Handbook - Evi Nemeth [98]
Command (m for help): new
e extended
p primary partition (1-4): p
Partition number (1-4): 2
First cylinder (256-5721, default 256): 256
Last cylinder or +size or +sizeM or +sizeK (256-1275, default 1275): 511
Command (m for help): type
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)
The third partition, which contains the rest of the disk, is defined in a similar manner. We review the partition table one last time before writing it.
Command (m for help): print
Disk /dev/sda: 255 heads, 63 sectors, 5721 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 255 2048256 83 Linux
/dev/sda2 256 511 2056320 82 Swap
/dev/sda3 512 5721 41849325 83 Linux
A star appears next to the number of blocks if the partition does not end on a cylinder boundary. You can either delete the partition and recreate it by entering a number of cylinders (as above), or live with the fact that a small bit of disk space may be unusable. We are happy with the new partition table, so we write the label out to disk:
Command (m for help): write
The partition table has been altered!
Calling ioctl() to re-read partition table.
SCSI device sda: hdwr sector=512 bytes. Sectors=91923356 [44884 MB] [44.9 GB]
sda: sda1 sda2 sda3
Syncing disks.
Some administrators like to reboot after writing the partition table to make sure everything is stable and consistent before they create the filesystems. It probably isn’t really necessary these days, but if you are used to installing Windows, you may feel more comfortable rebooting.
We’re now ready to create filesystems. The current de facto filesystem type for Linux is the Extended 2 filesystem (“ext2fs”), which is based on the Berkeley Fast File System (FFS). A variety of filesystem types are available for Linux, of which several appear to be potential future replacements for ext2fs. The procedure for creating new filesystems is roughly the same for most other types; however, very few filesystems provide a mkfs program.
To create an ext2fs filesystem, run mke2fs with the device and size of the partition on the command line. (The size can be found in the fdisk output above.)
# mke2fs /dev/sda1 2048256
mke2fs 1.14, 9-Jan-1999 for EXT2 FS 0.5b, 95/08/09
Linux ext2 filesystem format
514000 inodes, 2048001 blocks
102412 blocks (5.00%) reserved for the super user
First data block=1
Block size=1024 (log=0)
Fragment size=1024 (log=0)
250 block groups
8192 blocks per group, 8192 fragments per group
2056 inodes per group
Superblock backups stored on blocks:
8193, 16385, 24577, 32769, 40961, 49153, 57345, 65537,
...
Writing inode tables: 250/250 done
Writing superblocks and filesystem accounting information:
done
The process for creating the larger filesystem is the same, but it takes significantly longer. If you know that you will not need all of the inodes that mke2fs allocates by default, you can reduce the number of inodes per group, speeding up the mke2fs and giving you more space for real data. However, it’s much better to have too many inodes than too few, since running out of inodes will prevent you from creating any more files. You cannot add more inodes after the filesystem has been created.
We run fsck on our filesystems to make sure they were created properly. The -f flag forces fsck to check new filesystems rather than assuming that they are clean.
# fsck -f /dev/sda1
Parallelizing fsck version 1.14 (9-Jan-1999)
e2fsck 1.14, 9-Jan-1999 for EXT2 FS 0.5b, 95/08/09
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass