Linux 增加第二块硬盘 (虚拟机也使用)
在实际的运维过程中,会碰到/ 根目录下空间不足的时候,可以考虑在加快硬盘,挂在一个目录下;方法:在/ 根目录下建一个文件夹,把新加的硬盘mount 到这目录上。 step1;linux 下添加第二块scsi 硬盘如果是虚拟机的话,可以添加第二块虚拟硬盘方法是:VM -- setting -- hardware --hard Disk --add 就可以添加一块scsi 硬盘。
在实际的运维过程中,会碰到/ 根目录下空间不足的时候,
可以考虑在加快硬盘,挂在一个目录下;
方法:在/ 根目录下建一个文件夹,把新加的硬盘mount 到这目录上。
step1;
linux 下添加第二块scsi 硬盘
如果是虚拟机的话,可以添加第二块虚拟硬盘
方法是:VM -- setting -- hardware --hard Disk --add 就可以添加一块scsi 硬盘。
step2: shutdown the vmware
在restart 就可以看到:
在虚拟的启动过程中就可以看到:
sda: sdb 的启动,就证明刚才的add disk success
原来没有add disk 的时候:
[root@sheng /]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 776 2096482+ 82 Linux swap / Solaris
/dev/sda4 777 5221 35704462+ 5 Extended
/dev/sda5 777 5221 35704431 83 Linux
增加后:需要重启:
[root@sheng ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 776 2096482+ 82 Linux swap / Solaris
/dev/sda4 777 5221 35704462+ 5 Extended
/dev/sda5 777 5221 35704431 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
[root@sheng ~]#
下面要进行的是分区, add partition:
[root@sheng ~]# 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.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@sheng ~]#
[root@sheng ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6 48163+ 83 Linux
/dev/sda2 7 515 4088542+ 83 Linux
/dev/sda3 516 776 2096482+ 82 Linux swap / Solaris
/dev/sda4 777 5221 35704462+ 5 Extended
/dev/sda5 777 5221 35704431 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux
step3:
下面进行格式化:
把这个分区格式化 成 ext3 的格式,再创建文件系统
mkfs -t ext3 /dev/sdb1
step4:
创建mount point:
cd /
mkdir app
mount -t ext3 /dev/sdb1 /app
[root@sheng /]# mount -t ext3 /dev/sdb1 /app
[root@sheng /]# mount
/dev/sda2 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/sda5 on /home type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
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)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
/dev/sdb1 on /app type ext3 (rw)
看到最后一行多了一行 : /dev/sdb1 被mount 上了。
[root@sheng /]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 3960348 2420776 1335148 65% /
/dev/sda5 34586028 180280 32620528 1% /home
/dev/sda1 46633 10516 33709 24% /boot
tmpfs 275812 0 275812 0% /dev/shm
/dev/sdb1 2063504 35880 1922804 2% /app
可以看到 /app 的used % 是2% ,这样就大大减小了 / 根目录的负担。达到目的。呵呵
哦,特别要注意的是:
最后要update /etc/fstab ,增加一行:
/dev/sdb1 /app ext3 defaults 1 2
不然下次启动的话,不会生效.
更多推荐
所有评论(0)