ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 虚拟机下linux OS如何给系统添加磁盘

虚拟机下linux OS如何给系统添加磁盘

原创 Linux操作系统 作者:zhangsharp20 时间:2015-01-28 17:03:35 0 删除 编辑

增加磁盘空间

1、  在虚拟机上创建新的硬盘


一直下一步至选固定大小


创建完成


2、  切片

[root@node2 ~]# fdisk -l

 

Disk /dev/sda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1044     8281507+  8e  Linux LVM

 

Disk /dev/sdb: 17.1 GB, 17179869184 bytes

255 heads, 63 sectors/track, 2088 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

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

[root@node2 ~]# 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.

 

 

The number of cylinders for this disk is set to 2088.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

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-2088, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-2088, default 2088):

Using default value 2088

 

Command (m for help): p

 

Disk /dev/sdb: 17.1 GB, 17179869184 bytes

255 heads, 63 sectors/track, 2088 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2088    16771828+  83  Linux

 

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): L

 

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       bf  Solaris       

 1  FAT12           24  NEC DOS         81  Minix / old Lin c1  DRDOS/sec (FAT-

 2  XENIX root      39  Plan 9          82  Linux swap / So c4  DRDOS/sec (FAT-

 3  XENIX usr       3c  PartitionMagic  83  Linux           c6  DRDOS/sec (FAT-

 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c7  Syrinx        

 5  Extended        41  PPC PReP Boot   85  Linux extended  da  Non-FS data   

 6  FAT16           42  SFS             86  NTFS volume set db  CP/M / CTOS / .

 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set de  Dell Utility  

 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext df  BootIt        

 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       e1  DOS access    

 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e3  DOS R/O       

 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e4  SpeedStor     

 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          eb  BeOS fs       

 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi ee  EFI GPT       

 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ef  EFI (FAT-12/16/

10  OPUS            55  EZ-Drive        a6  OpenBSD         f0  Linux/PA-RISC b

11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f1  SpeedStor     

12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f4  SpeedStor     

14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f2  DOS secondary 

16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     fb  VMware VMFS   

17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep       

1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT           

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@node2 ~]#

 

2、  将LVM做成物理卷

[root@node2 ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

3、  将物理卷分割成多个卷组

[root@node2 ~]# vgcreate u01vg /dev/sdb1

  /dev/hdc: open failed: Read-only file system

  /dev/cdrom: open failed: Read-only file system

  Attempt to close device '/dev/cdrom' which is not open.

  /dev/cdrom: open failed: Read-only file system

  Attempt to close device '/dev/cdrom' which is not open.

  /dev/cdrom: open failed: Read-only file system

  Attempt to close device '/dev/cdrom' which is not open.

  Volume group "u01vg" successfully created

[root@node2 ~]# vgdisplay

  --- Volume group ---

  VG Name               u01vg

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  1

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               15.99 GB

  PE Size               4.00 MB

  Total PE              4094

  Alloc PE / Size       0 / 0  

  Free  PE / Size       4094 / 15.99 GB

  VG UUID               mxsb13-VJ2U-7D9u-edwb-a3xu-b56f-pMR3UW

  

  --- Volume group ---

  VG Name               VolGroup00

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               2

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               7.88 GB

  PE Size               32.00 MB

  Total PE              252

  Alloc PE / Size       252 / 7.88 GB

  Free  PE / Size       0 / 0  

  VG UUID               QRFpCD-75Mk-LPY8-s5r0-Z14C-EdyU-tzIe86

  

[root@node2 ~]#

将vg激活

[root@node2 ~]# vgchange -ay u01vg

0 logical volume(s) in volume group "u01vg" now active

4、  创建LV逻辑卷

[root@node2 ~]# lvcreate -L 16360M -n u01lv u01vg

/dev/hdc: open failed: Read-only file system

Logical volume "u01lv" created

[root@node2 ~]# vgdisplay u01vg

  --- Volume group ---

  VG Name               u01vg

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  2

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               0

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               15.99 GB

  PE Size               4.00 MB

  Total PE              4094

  Alloc PE / Size       4090 / 15.98 GB

  Free  PE / Size       4 / 16.00 MB

  VG UUID               mxsb13-VJ2U-7D9u-edwb-a3xu-b56f-pMR3UW

5、  查看是否创建成功

[root@node2 ~]# ls /dev/u01vg/u01lv

/dev/u01vg/u01lv

[root@node2 ~]#

6、  创建文件系统

[root@node2 ~]# mkfs.ext3 /dev/u01vg/u01lv

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

2097152 inodes, 4188160 blocks

209408 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4290772992

128 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

 

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@node2 ~]#

7、  挂载

挂载前

[root@node2 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      5.7G  3.1G  2.4G  56% /

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 861M     0  861M   0% /dev/shm

挂载后

[root@node2 ~]# mount /dev/u01vg/u01lv /u01/

[root@node2 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      5.7G  3.1G  2.4G  56% /

/dev/sda1              99M   12M   82M  13% /boot

tmpfs                 861M     0  861M   0% /dev/shm

/dev/mapper/u01vg-u01lv

                       16G  173M   15G   2% /u01

[root@node2 ~]#

9、为了保证每次开机自动MOUNT该设备,将将此设备信息写入vi /etc/fstab

 

[root@node2 ~]# vi /etc/fstab

 

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   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

/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

/dev/u01vg/u01lv       /u01                    ext3     defaults        0 0

~


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29802484/viewspace-1418466/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Linux添加SWAP
请登录后发表评论 登录
全部评论

注册时间:2014-08-12

  • 博文量
    382
  • 访问量
    801413