linux 磁碟分割

來源:互聯網
上載者:User

標籤:

【知識點】

linux命令: df   fdisk mount/unmount

【步驟】1. 查看磁碟資訊  fdisk -l

[[email protected] dev]# fdisk -l
Disk /dev/vda: 4294 MB, 4294967296 bytes
43 heads, 32 sectors/track, 6096 cylinders
Units = cylinders of 1376 * 512 = 704512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dcf96
Device Boot Start End Blocks Id System
/dev/vda1 * 2 6097 4193280 83 Linux
Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes
16 heads, 63 sectors/track, 4161015 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb29abbe6
Device Boot Start End Blocks Id System
/dev/vdb1 1 208052 104858176+ 83 Linux
/dev/vdb2 208053 2288561 1048576536 83 Linux

2. 添加分區 fdisk 磁碟

    fdisk /dev/vdb   #在磁碟/dev/vdb劃分磁碟

[[email protected] dev]# fdisk /dev/vdb
WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
switch off the mode (command ‘c‘) and change display units to
sectors (command ‘u‘).
Command (m for help): n          #添加分區
Command action
e extended
p primary partition (1-4)
p                                             #添加主要磁碟分割
Partition number (1-4): 3          
First cylinder (2288562-4161015, default 2288562):
Using default value 2288562
Last cylinder, +cylinders or +size{K,M,G} (2288562-4161015, default 4161015): +50G
Command (m for help): w                   #寫入分區
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

3. 格式化磁碟

  mkfs.exts4 /dev/vdb3

備忘:格式分區方法

mkfs - 支援ext2、ext3(日誌)、vfat、msdos、jfs、reiserfs等

用法1:mkfs -t <fstype> <partition>

例:#mkfs -t ext3 /dev/hda1

用法2:mkfs.<fstype> <partition>

例:#mkfs.vfat /dev/hda2

4. 掛載分區

  mount /dev/vdb3 /home

5. 寫入/etc/fstab檔案

  以上操作,在系統重啟後,swap檔案的大小又會變回原大小,我們可以在/etc/fstab裡增加下面的配置,使其重啟後,我們剛剛的配置仍然有效。添加如下:

/dev/vdb1 /u01 ext4 defaults 0 0

/dev/vdb2 /data ext4 defaults 0 0

/dev/vdb3 /home ext4 defaults 0 0

/dev/vdb4 swap swap defaults 0 0

linux 磁碟分割

聯繫我們

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