日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux——使用fidsk对linux硬盘进行操作【转】

發(fā)布時(shí)間:2025/3/13 linux 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux——使用fidsk对linux硬盘进行操作【转】 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本文轉(zhuǎn)自:http://www.liusuping.com/ubuntu-linux/linux-fdisk-disk.html

fdisk是linux自帶的硬盤(pán)分區(qū)工具,可以對(duì)硬盤(pán)進(jìn)行分區(qū),或者對(duì)硬盤(pán)分區(qū)進(jìn)行調(diào)整。本次試驗(yàn)環(huán)境請(qǐng)參考[Linux磁盤(pán)系統(tǒng)基礎(chǔ)知識(shí)]

首先選擇要進(jìn)行操作的磁盤(pán)

[root@a ~]# fdisk /dev/sdb

輸入m,列出可以執(zhí)行的命令

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)

輸入p,列出磁盤(pán)目前的分區(qū)情況

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1?????????? 1??????? 8001?? 8e? Linux LVM
/dev/sdb2?????????????? 2????????? 26????? 200812+? 83? Linux

輸入d,然后選擇分區(qū),刪除現(xiàn)有分區(qū)

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Selected partition 2

查看分區(qū)情況,確認(rèn)分區(qū)已經(jīng)刪除

Command (m for help): print

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

?? Device Boot????? Start???????? End????? Blocks?? Id? System

Command (m for help):

輸入n,建立新的磁盤(pán)分區(qū),首先建立兩個(gè)主磁盤(pán)分區(qū)

Command (m for help): n
Command action
?? e?? extended
?? p?? primary partition (1-4)
p????//建立主分區(qū)
Partition number (1-4): 1??//分區(qū)號(hào)
First cylinder (1-391, default 1):??//分區(qū)起始位置
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): 100??//分區(qū)結(jié)束位置,單位為扇區(qū)

Command (m for help): n? //再建立一個(gè)分區(qū)
Command action
?? e?? extended
?? p?? primary partition (1-4)
p??
Partition number (1-4): 2? //分區(qū)號(hào)為2
First cylinder (101-391, default 101):?
Using default value 101
Last cylinder or +size or +sizeM or +sizeK (101-391, default 391): +200M? //分區(qū)結(jié)束位置,單位為M

確認(rèn)分區(qū)建立成功

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1???????? 100????? 803218+? 83? Linux
/dev/sdb2???????????? 101???????? 125????? 200812+? 83? Linux

再建立一個(gè)邏輯分區(qū)

Command (m for help): n
Command action
?? e?? extended
?? p?? primary partition (1-4)
e??//選擇擴(kuò)展分區(qū)
Partition number (1-4): 3
First cylinder (126-391, default 126):?
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-391, default 391):?
Using default value 391

確認(rèn)擴(kuò)展分區(qū)建立成功

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1???????? 100????? 803218+? 83? Linux
/dev/sdb2???????????? 101???????? 125????? 200812+? 83? Linux
/dev/sdb3???????????? 126???????? 391???? 2136645??? 5? Extended

在擴(kuò)展分區(qū)上建立兩個(gè)邏輯分區(qū)

Command (m for help): n
Command action
?? l?? logical (5 or over)
?? p?? primary partition (1-4)
l //選擇邏輯分區(qū)
First cylinder (126-391, default 126):?
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-391, default 391): +400M????

Command (m for help): n
Command action
?? l?? logical (5 or over)
?? p?? primary partition (1-4)
l
First cylinder (176-391, default 176):?
Using default value 176
Last cylinder or +size or +sizeM or +sizeK (176-391, default 391):?
Using default value 391

確認(rèn)邏輯分區(qū)建立成功

Command (m for help): p

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1???????? 100????? 803218+? 83? Linux
/dev/sdb2???????????? 101???????? 125????? 200812+? 83? Linux
/dev/sdb3???????????? 126???????? 391???? 2136645??? 5? Extended
/dev/sdb5???????????? 126???????? 175????? 401593+? 83? Linux
/dev/sdb6???????????? 176???????? 391???? 1734988+? 83? Linux

Command (m for help):

從上面的結(jié)果我們可以看到,在硬盤(pán)sdb我們建立了2個(gè)主分區(qū)(sdb1,sdb2),1個(gè)擴(kuò)展分區(qū)(sdb3),2個(gè)邏輯分區(qū)(sdb5,sdb6)

注意:主分區(qū)和擴(kuò)展分區(qū)的磁盤(pán)號(hào)位1-4,也就是說(shuō)最多有4個(gè)主分區(qū)或者擴(kuò)展分區(qū),邏輯分區(qū)開(kāi)始的磁盤(pán)號(hào)為5,因此在這個(gè)實(shí)驗(yàn)中試沒(méi)有sdb4的。

最后對(duì)分區(qū)操作進(jìn)行保存

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

建立好分區(qū)之后我們還需要對(duì)分區(qū)進(jìn)行格式化才能在系統(tǒng)中使用磁盤(pán)。

在sdb1上建立ext2分區(qū)

[root@a ~]#?mkfs.ext2 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
100576 inodes, 200804 blocks
10040 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=209715200
7 block groups
32768 blocks per group, 32768 fragments per group
14368 inodes per group
Superblock backups stored on blocks:?
??????? 32768, 98304, 163840

Writing inode tables: done????????????????????????????
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.

在sdb6上建立ext3分區(qū)

[root@a ~]#?mkfs.ext3 /dev/sdb6
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
217280 inodes, 433747 blocks
21687 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=444596224
14 block groups
32768 blocks per group, 32768 fragments per group
15520 inodes per group
Superblock backups stored on blocks:?
??????? 32768, 98304, 163840, 229376, 294912

Writing inode tables: done????????????????????????????
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@a ~]#

建立兩個(gè)目錄/oracle和/web,將新建好的兩個(gè)分區(qū)掛載到系統(tǒng)

[root@a ~]# mkdir /oracle
[root@a ~]# mkdir /web
[root@a ~]# mount /dev/sdb1 /oracle
[root@a ~]# mount /dev/sdb6 /web

查看分區(qū)掛載情況

[root@a ~]# df -h
文件系統(tǒng)????????????? 容量? 已用 可用 已用% 掛載點(diǎn)
/dev/mapper/VolGroup00-LogVol00
????????????????????? 6.7G? 2.8G? 3.6G? 44% /
/dev/sda1????????????? 99M?? 12M?? 82M? 13% /boot
tmpfs???????????????? 125M???? 0? 125M?? 0% /dev/shm
/dev/sdb1???????????? 773M? 808K? 733M?? 1% /oracle
/dev/sdb6???????????? 1.7G?? 35M? 1.6G?? 3% /web

如果需要每次開(kāi)機(jī)自動(dòng)掛載則需要修改/etc/fstab文件,加入兩行配置

[root@a ~]# vim /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/sdb1?????????????? /oracle???????????????? ext2??? defaults??????? 0 0
/dev/sdb6?????????????? /web??????????????????? ext3??? defaults??????? 0 0

轉(zhuǎn)載于:https://www.cnblogs.com/sheropan/p/5012505.html

總結(jié)

以上是生活随笔為你收集整理的linux——使用fidsk对linux硬盘进行操作【转】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。