Documente Academic
Documente Profesional
Documente Cultură
# fdisk -l /dev/sda
to change the partitions on a drive without partition table, such as a new drive, use fdisk
eg. fdisk /dev/sdb
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
e2label
Usage of e2label is simple. manpage for e2label shows following command line options,
# e2label /dev/sda1
/boot
# e2label /dev/sda3
/
# e2label /dev/sda3
/changed-label
if you want the server to be able to boot next time round, ensure changes are made to
/etc/fstab as well. Otherwise, on the next boot, you may be prompted with errors, eg.
in which case, you can boot up with a rescue disk, eg. CentOS installation disk, enter
"linux rescue" at prompt; chroot /mnt/sysimage and edit /etc/fstab accordingly.
Alternatively, if you are prompted for root password, and gets a shell, you may be able
to edit /etc/fstab. If the filesystem is readonly, remount the filesytem readwrite. eg.
mount -o remount,rw /
mount, umount
2 partitions to be created
100MB and rest of the drive
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous content won't be
recoverable.
# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
26104 inodes, 104388 blocks
5219 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
# mkfs.ext3 /dev/sdb2
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
9076736 inodes, 18125336 blocks
906266 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
554 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
next: use e2label to label the volumes. Although both mkfs3.ext and
tune2fs is capable of labelling, with the -L option, I am deliberately
using e2label in this example to demonstrate the use of e2label.
# e2label /dev/sdb1
/drive2-100MB
the description used was too long, and got truncated. maximum for label is 16
characters.
mount shows what has already been mounted. in addition, the -l option shows the
filesystem label
# mount -l
/dev/sda3 on / type ext3 (rw) [/]
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw) [/boot]
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
We are mainly concerned with the drives, so let's grep for the relevent entries
unmount can also use the mount point instead of the device, eg.
# umount /mountpt1
# umount /mountpt2
# mount -l |grep /dev/sd
/dev/sda3 on / type ext3 (rw) [/]
/dev/sda1 on /boot type ext3 (rw) [/boot]
next: edit /etc/fstab, add in entries for the new drive if we want it to be mounted at boot
up.
following is existing /etc/fstab for the server, which was installed for purpose of this
tutorial,
mount has a -a option which reads /etc/fstab and mounts all filesystems mentioned in
the file,
# mount -a
# mount -l |grep /dev/sd
/dev/sda3 on / type ext3 (rw) [/]
/dev/sda1 on /boot type ext3 (rw) [/boot]
/dev/sdb1 on /mountpt1 type ext3 (rw) [/drive2-100MB]
/dev/sdb2 on /mountpt2 type ext3 (rw) [/drive2-restofdr]
next, reboot, and ensure the new drive is mounted automatically, and accessible via the
mount points, /mountpt1, /mountpt2