【背景】 原/ftp分区空间不足
【需求】新增一颗硬盘,将/ftp分区挂载点指向新硬盘.
【操作步骤】
1. 新增硬盘,并分区\格式化;
[root@bjftp01 ~]# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20482843+ 83 Linux
/dev/sda2 2551 2805 2048287+ 82 Linux swap / Solaris
/dev/sda3 2806 19457 133757190 83 Linux
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 60801 488384001 83 Linux
新硬盘分区:
[root@bjftp01 ~]# fdisk /dev/sdb
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
m print this menu
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
新增一个主分区:/dev/sdb1
完成后按W保存退出
新分区格式化:
mkfs.ext3 /dev/sdb1
挂载测试:
mount /dev/sdb1 /mnt/ftpnew/
2.同步原/ftp资料到新分区
rsync -avp /ftp/ /mnt/ftpnew/
3.修改/etc/fstab
LABEL=/ / ext3 defaults 1 1
#LABEL=/ /ftp ext3 defaults 1 2
/dev/sda3 /ftpbk ext3 defaults 1 2
/dev/sdb1 /ftp ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
修改完成需重启系统才可以生效.
如修改有问题会无法启动系统,进入到single模式检查修改配置即可.
注意:single模式下系统为只读,无法直接修改/etc/fstab文件,需先执行如下命令:
mount -o remount,rw / 逗号前无空格,一定要有/这个
重新挂载为 读写模式。
再 vi /etc/fstab 发现已经可以修改了,修改完毕,重启,正常。
4.系统启动,验证新分区和旧分区的资料.
[root@bjftp01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 13G 5.7G 69% /
/dev/sda3 124G 124G 0 100% /ftpbk
/dev/sdb1 459G 125G 312G 29% /ftp
tmpfs 377M 0 377M 0% /dev/shm
none 377M 104K 377M 1% /var/lib/xenstored
[root@bjftp01 ftp]# ll
total 60
drwxr-xr-x 3 root root 4096 May 14 2014 Software
[root@bjftp01 ftpbk]# ll
total 44
drwxr-xr-x 3 root root 4096 May 14 2014 Software
5.都没问题,finished!