一天一點學習Linux之檔案系統屬性更改相關操作

來源:互聯網
上載者:User

 

檔案系統屬性的查看

dumpe2fs 顯示檔案系統的super block和blocks group的資訊

不加參數將顯示全部的內容

-h :僅列出superblock 的資料

 

superblock 常用的顯示內容注釋如下

 

Filesystem volume name: <none> <==檔案系統的標籤

Last mounted on: / <==此檔案系統的掛載點

Filesystem UUID: 8e4f6141-20f9-4f5a-aad4-bac048374152 <==此檔案系統的代號

 

Default mount options: user_xattr acl <==預設的掛載選項

 

Inode count: 960992 <==Inode的數量

Block count: 3840000 <==Block的數量

Reserved block count: 192000 <==保留的塊數量

Free blocks: 3093336 <==剩餘的地段數量

Free inodes: 855672 <==剩餘的Inode數量

First block: 0

Block size: 4096 <==塊的大小為4K

 

Mount count: 21 <==檔案系統被掛載的次數

Maximum mount count: -1 <==檔案被掛載多少次後需要FSCK,如果是負數或者是0的話,就永遠不會自檢了

 

Reserved blocks uid: 0 (user root) <==為某個使用者保留的塊

Reserved blocks gid: 0 (group root) <==為某個組保留的塊

First inode: 11

Inode size: 256 <==Inode的大小

 

 

以上都是supberblock的相關資訊,如果想看Block Group的相關資訊,可以用dumpe2fs命令,不加參數。supberblock下面以Group開頭的就是Block Group的相關資訊了

Group *: <==這些都是block group的資訊

 

 

 

查看檔案系統的UUID

blkid

[root@yufei ~]# blkid

/dev/sda1: UUID=”744b208e-0951-40e1-a4ae-1ece29840ddb”TYPE=”ext4″LABEL=”/dev/sda1″

/dev/sda2: UUID=”c70cd6a4-09cd-4aea-ba94-f3641df4e981″TYPE=”swap“

 

ls -l /dev/disk/by-uuid/

[root@yufei ~]# ls -l /dev/disk/by-uuid/

total 0

lrwxrwxrwx. 1 root root 10 Apr 4 12:37 744b208e-0951-40e1-a4ae-1ece29840ddb -> ../../sda1

lrwxrwxrwx. 1 root root 10 Apr 4 12:37 c70cd6a4-09cd-4aea-ba94-f3641df4e981 -> ../../sda2

 

查看磁碟的檔案系統資訊

fdisk /dev/sda

[root@yufei ~]# fdisk /dev/sda

Command (m for help): p

 

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: 0x00093fdc

 

Device Boot Start End Blocks Id System

/dev/sda1 * 1 1913 15360000 83 Linux

/dev/sda2 1913 1978 524288 82 Linux swap / Solaris

q退出

這裡可以看到交換分區的資訊,如果用df是看不到交換分區的資訊的。關於fdisk這個分區命令的使用,後面還會詳細介紹。

 

調整檔案系統的參數

 

變更檔系統的標籤e2label

命令使用的格式

e2label 裝置名稱 新的Label名稱

註:不知道如何還原LABLE,如果有朋友知道的話,可以留言分享一下。謝謝!

 

tune2fs調整/查看ext2/ext3/ext4檔案系統的參數

常用選項說明:

-l 查看檔案系統資訊 相當於dumpe2fs -h查看到的資訊

 

-c max-mount-counts 設定強制自檢的掛載次數,如果開啟,每掛載一次mount conut就會加1,超過此次數後就會強制自檢

 

-i interval-between-checks[d|m|w] 設定強制自檢的時間間隔[d天m月w周]

 

-m reserved-blocks-percentage 設定保留塊的百分比

-r reserved-blocks-count 設定保留塊多少

 

-L volume-label 設定/修改檔案系統的標籤。類似e2label的功能。

 

-o [^]mount-option[,...] Set or clear the indicated default mount options in the filesystem. 設定或清除預設掛載的檔案系統選項

tune2fs -o ^acl /dev/sda1清除acl屬性

tune2fs -o +acl /dev/sda1

 

-u uid

-g gid

設定保留blocks的使用者和使用者組

 

-U UUID

如何獲得UUID資訊

uuidgen會動態獲得檔案系統的UUID資訊,可以根據自己的喜好來改。

他有兩個參數

-r隨機獲得

-t根據時間隨機獲得

注意:修改過後,你需要修改對應的/etc/fstab和/boot/grub/menu.lst這兩個檔案,否則你的系統就啟動不了。我在做實驗的時候,把fstab這個檔案裡面的改了,忘記了menu.lst檔案,導致找不到啟動裝置。

 

關於block和inode的數量和大小,這些是在建立檔案系統時候產生的,如果想改變的話,就需要重新對其格式化

摘自 羽飛部落格

聯繫我們

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