虛擬機器CentOS系統硬碟擴容

來源:互聯網
上載者:User

虛擬機器CentOS系統硬碟擴容

裝好CentOS後,發現空間太小,怎樣才能增加硬碟容量?那就是再建一個硬碟:

開啟虛擬經濟的設定添加硬碟

查看現有的磁碟空間

fdisk -l

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e4bd8

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          64      512000  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496  8e  Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

我添加的是/dev/sdb

給新加的硬碟進行分區

fdisk /dev/sdb

輸入m ,可以查看協助資訊

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):

增加新的分區

command (m for help):n

選擇基本資料分區,輸入:p

Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)

斷行符號

 First cylinder (1-15908,default 1):Enter
(這是斷行符號是指分的預設大小)
    寫入並退出
        command (m for help):w

然後格式化磁碟分割
 用ext4格式對/dev/sdb1進入格式化

mkfs.ext4 /dev/sdb1

[root@localhost ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
無論如何也要繼續? (y,n) y
/dev/sdb 已經掛載;will not make a 檔案系統 here!
[root@localhost ~]#

因為我的擴充盤符已經掛上去了,在佔用狀態。

掛載分區

先建立一個掛載點

mkdir  /work

mount -t ext4 /dev/sdb1/work

查看掛載狀態

df -h

[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root  18G  11G  6.2G  63% /
tmpfs                        932M  72K  932M  1% /dev/shm
/dev/sda1                    485M  40M  421M  9% /boot
/dev/sdb                      5.0G  138M  4.6G  3% /work
[root@localhost ~]#

將掛載的目錄加入開機自動掛載

  /dev/sdb1 /work ext4 errors=remount-ro 0 1

完成。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.