使用fdisk結合partprobe命令不重啟系統添加一塊新的磁碟分割

來源:互聯網
上載者:User

使用fdisk結合partprobe命令不重啟系統添加一塊新的磁碟分割 主機內建硬碟超過300GB,目前只劃分使用了3個主要磁碟分割,不到70GB,如 下:[root@db2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 29G 3.7G  24G 14% / /dev/sda2 29G  22G 5.2G 81% /oracle tmpfs    2.0G    0 2.0G  0% /dev/shm  [root@db2 ~]# cat /proc/partitionsmajor minor  #blocks  name    8     0  311427072 sda    sda1   8     2   30716280 sda2   8     3    8193150 sda3   8    16     976896 sdb   8    32     976896 sdc 現在需要給系統添加1個100GB的空間存放資料檔案,而又不影響現有系統上業務的運行,使用fdisk結合partprobe命令不重啟系統添加 一塊新的磁碟分割。操作步驟如下: 第1步,添加新的磁碟分割 [root@db2 ~]# fdisk /dev/sdaThe number of cylinders for this disk is set to 38770.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) Command (m for help): p Disk /dev/sda: 318.9 GB, 318901321728 bytes255 heads, 63 sectors/track, 38770 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  System/dev/sda1   *           1        3824    30716248+  83  Linux/dev/sda2            3825        7648    30716280   83  Linux/dev/sda3            7649        8668     8193150   82  Linux swap / Solaris Command (m for help): nCommand action   e   extended   p   primary partition (1-4)pSelected partition 4First cylinder (8669-38770, default 8669):Using default value 8669Last cylinder or +size or +sizeM or +sizeK (8669-38770, default 38770): +100G   Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16:   Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.Syncing disks.[root@db2 ~]#  第2步,使用工具partprobe讓kernel讀取分區資訊 [root@db2 ~]# partprobe使用fdisk工具只是將分區資訊寫到磁碟,如果需要mkfs磁碟分割則需要重啟系統,而使用partprobe則可以使kernel重新讀取分區 資訊,從而避免重啟系統。 第3步,格式檔案系統 [root@db2 ~]# mkfs.ext3 /dev/sda4mke2fs 1.39 (29-May-2006)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)12222464 inodes, 24416791 blocks1220839 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296746 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,     2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 26 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@db2 ~]# 第4步,mount新的分區/dev/sda4 [root@db2 ~]# e2label  /dev/sda4 /data[root@db2 ~]# mkdir /data[root@db2 ~]# mount /dev/sda4 /data[root@db2 ~]# dfFilesystem           1K-blocks      Used Available Use% Mounted on/dev/sda1             29753556   3810844  24406900  14% //dev/sda2             29753588  11304616  16913160  41% /oracletmpfs                  2023936         0   2023936   0% /dev/shm/dev/sda4             96132968    192312  91057300   1% /data[root@db2 ~]# 總結:使用partprobe可以不用重啟系統即可配合fdisk工具建立新的分區。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.