为ubuntu增加磁盘如下图所示:
输入sudo fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3991
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 80709631 40353792 83 Linux
/dev/sda2 80711678 83884031 1586177 5 Extended
/dev/sda5 80711680 83884031 1586176 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
刚才添加的10G已经显示出来了。
sudo fdisk /dev/sdb
ommand (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
Using default value 20971519
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
myroot@ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3991
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 80709631 40353792 83 Linux
/dev/sda2 80711678 83884031 1586177 5 Extended
/dev/sda5 80711680 83884031 1586176 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
107 heads, 17 sectors/track, 11529 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x73667eff
Device Boot Start End Blocks Id System
/dev/sdb1 2048 20971519 10484736 83 Linux
格式化分区:
sudo mkfs.ext3 /dev/sdb1
挂载分区到/opt目录,mount /dev/sdb1 /opt:
myroot@ubuntu:~$ df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 39G 4.0G 33G 11% /
udev 755M 4.0K 755M 1% /dev
tmpfs 305M 792K 304M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 762M 152K 762M 1% /run/shm
/dev/sdb1 9.9G 151M 9.2G 2% /opt
卸载/opt,sudo umount /opt