您的位置:首页 > 其它

ubuntu增加磁盘

2016-04-10 22:23 288 查看
步骤:

1、虚拟机–设置–添加,选择硬盘添加,如 SSCI类型, 2G大小。

2、开机,切换root操作;

3、可以先fdisk -l先查看下情况

root@ubuntu:~# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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: 0x00021f26

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 499711 248832 83 Linux

/dev/sda2 501758 41940991 20719617 5 Extended

/dev/sda5 501760 41940991 20719616 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders, total 4194304 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

Disk /dev/sdb doesn’t contain a valid partition table

Disk /dev/mapper/ubuntu–vg-root: 13.9 GB, 13925089280 bytes

255 heads, 63 sectors/track, 1692 cylinders, total 27197440 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

Disk /dev/mapper/ubuntu–vg-root doesn’t contain a valid partition table

Disk /dev/mapper/ubuntu–vg-swap_1: 1069 MB, 1069547520 bytes

255 heads, 63 sectors/track, 130 cylinders, total 2088960 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

4、前面加粗部分说明还不可用。此时要创建此磁盘分区。输入命令:fdisk /dev/sdb。如下,按m显示可用命令提示符。

root@ubuntu:~# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x6472c219.

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)

5、键入:n,添加新分区,键入:p,选择添加主分区,键入:l,选择主分区编号为1,这样创建后的主分区为sdb1,之后,fdisk会让你选择该分区的开始值和结束值,直接回车,最后键入:w,保存所有并退出,完成新硬盘的分区。

Command (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-4194303, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303):

Using default value 4194303

Command (m for help): v

Partitions 1: cylinder 262 greater than maximum 261

Partition 1: previous sectors 4194303 disagrees with total 4196811

Remaining 2047 unallocated 512-byte sectors

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders, total 4194304 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: 0x6472c219

Device Boot Start End Blocks Id System

/dev/sdb1 2048 4194303 2096128 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

6、fdisk -l 再看看:

root@ubuntu:~# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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: 0x00021f26

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 499711 248832 83 Linux

/dev/sda2 501758 41940991 20719617 5 Extended

/dev/sda5 501760 41940991 20719616 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes

22 heads, 16 sectors/track, 11915 cylinders, total 4194304 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: 0x6472c219

Device Boot Start End Blocks Id System

/dev/sdb1 2048 4194303 2096128 83 Linux

Disk /dev/mapper/ubuntu–vg-root: 13.9 GB, 13925089280 bytes

255 heads, 63 sectors/track, 1692 cylinders, total 27197440 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

Disk /dev/mapper/ubuntu–vg-root doesn’t contain a valid partition table

Disk /dev/mapper/ubuntu–vg-swap_1: 1069 MB, 1069547520 bytes

255 heads, 63 sectors/track, 130 cylinders, total 2088960 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

6、格式化为ext3格式:mkfs -t ext3 /dev/sdb1

7、创建挂载目录和挂载。

mkdir gaoyf

mount /dev/sdb1 gaoyf/

8、查看

root@ubuntu:/# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/mapper/ubuntu–vg-root 13254160 1291720 11266120 11% /

none 4 0 4 0% /sys/fs/cgroup

udev 488956 4 488952 1% /dev

tmpfs 100020 1556 98464 2% /run

none 5120 0 5120 0% /run/lock

none 500096 0 500096 0% /run/shm

none 102400 0 102400 0% /run/user

/dev/sda1 240972 38816 189715 17% /boot

/dev/sdb1 2030416 3108 1922504 1% /gaoyf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu 硬盘 虚拟机