亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 10545 | 回復(fù): 6
打印 上一主題 下一主題

EXT3文件系統(tǒng)收縮和擴容 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2009-07-01 01:44 |只看該作者 |倒序瀏覽
查看系統(tǒng)現(xiàn)在結(jié)構(gòu)
[root@seker /]# fdisk -l

Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1122      522112+  82  Linux swap / Solaris
/dev/sda4            1123        2088     7759395    5  Extended
[root@seker /]#

[root@seker /]# df -Th
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda2     ext3    7.8G  3.0G  4.5G  40% /
/dev/sda1     ext3     99M   15M   80M  16% /boot
tmpfs        tmpfs    125M     0  125M   0% /dev/shm
[root@seker /]#

根據(jù)上面輸出,先計算出一個值來,我們以后要用到:
sda1 = 100M 從柱面1到柱面13. 也就是說12個柱面是100M空間

1.
在邏輯分區(qū)建立一個新的分區(qū) 大小為300M

[root@seker /]# fdisk /dev/sda

The number of cylinders for this disk is set to 2088.
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): n
First cylinder (1123-2088, default 1123):
Using default value 1123
Last cylinder or +size or +sizeM or +sizeK (1123-2088, default 2088): +300M

Command (m for help): p

Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1122      522112+  82  Linux swap / Solaris
/dev/sda4            1123        2088     7759395    5  Extended
/dev/sda5            1123        1159      297171   83  Linux

Command (m for help): w

這里,再計算一下 給sda5 300M 使用柱面恰好是占用了 1159 - 1123 = 36 個.和我們前面計算的100M=12個柱面相吻合

[root@seker /]# partprobe /dev/sda
[root@seker /]# mke2fs -j /dev/sda5
讓你新建的分區(qū)馬上生效,之后再格式化成ext3.

[root@seker /]# mount /dev/sda5 /mnt
[root@seker /]# cp /etc/rc.d/init.d/* /mnt/
[root@seker /]# ls /mnt/ | wc -l
74
[root@seker /]# sync;sync
[root@seker /]#
將新分區(qū)掛載 并寫入寫文件進去.現(xiàn)在時74個文件在新分區(qū)上.

2.
一切準(zhǔn)備就緒,我們先縮小它.
[root@seker /]# umount /mnt
[root@seker /]#
要想縮小或者是放大,都必須要離線.

[root@seker /]# tune2fs -O ^has_journal /dev/sda5
tune2fs 1.39 (29-May-2006)
刪除分區(qū)上的日志,也就是把系統(tǒng)先轉(zhuǎn)化成ext2格式.(也可以不做這里的轉(zhuǎn)換,直接用ext3的就支持.引用man: resize2fs - ext2/ext3 file system resizer.)

[root@seker /]# e2fsck -f /dev/sda5
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda5: 84/74296 files (2.4% non-contiguous), 11687/297168 blocks
[root@seker /]#
接著對文件系統(tǒng)做強制檢查.

[root@seker /]# resize2fs /dev/sda5 150M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/sda5 to 153600 (1k) blocks.
The filesystem on /dev/sda5 is now 153600 blocks long.

[root@seker /]# 開始收縮,收縮至150M

[root@seker /]# tune2fs -j /dev/sda5
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@seker /]# 再將ext2轉(zhuǎn)成ext3.


[root@seker /]# mount /dev/sda5 /mnt
[root@seker /]# df -Th /dev/sda5
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda5     ext3    146M  5.8M  134M   5% /mnt
[root@seker /]# ls /mnt/ | wc  -l
74
[root@seker /]# 驗證大小,以及上面的文件是否還在. 一切安好.

再做寫入測試
[root@seker mnt]# dd if=/dev/zero of=./big_file bs=5M count=28
dd: 寫入 “./big_file”: 設(shè)備上沒有空間
28+0 records in
27+0 records out
145690624 bytes (146 MB) copied, 2.58229 seconds, 56.4 MB/s
[root@seker mnt]#

[root@seker mnt]# df -Th /dev/sda5
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda5     ext3    146M  146M     0 100% /mnt
[root@seker mnt]# 寫到146M后提示空間已滿.

縮小成功.

3.放大
放大比縮小困難一點.因為縮小不需要去更改柱面位置.

[root@seker ~]# umount /mnt
[root@seker ~]# 還是必須離線

[root@seker ~]# tune2fs -O ^has_journal /dev/sda5
tune2fs 1.39 (29-May-2006)
[root@seker ~]# 還是轉(zhuǎn)化成ext2

[root@seker ~]# e2fsck -f /dev/sda5
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda5: 85/38152 files (2.4% non-contiguous), 149445/153600 blocks
[root@seker ~]# 還是強制檢查

[root@seker ~]# resize2fs /dev/sda5 500M
resize2fs 1.39 (29-May-2006)
The containing partition (or device) is only 297171 (1k) blocks.
You requested a new size of 512000 blocks.

[root@seker ~]# 嘗試加大已經(jīng)不好用了.提示只能是297171個blocks.因為分區(qū)時柱面結(jié)束為止被鎖定.

我們突破一下:
[root@seker ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 2088.
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: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1122      522112+  82  Linux swap / Solaris
/dev/sda4            1123        2088     7759395    5  Extended
/dev/sda5            1123        1159      297171   83  Linux

Command (m for help): d
Partition number (1-5): 5
        # 將sda5刪掉 不用擔(dān)心,數(shù)據(jù)不會丟.之后馬上新建.
Command (m for help): n
First cylinder (1123-2088, default 1123):
Using default value 1123
Last cylinder or +size or +sizeM or +sizeK (1123-2088, default 2088):
        # 結(jié)束的柱面位置是關(guān)鍵.我們在上面算過了100M用到12個柱面,現(xiàn)在我想擴大到500M
        # 那么就是從開始位置(1123)處再加上12*5的數(shù)值 結(jié)果就是1183
        # 那就在lasr cylinder:這里輸出:1183

Command (m for help): p

/dev/sda5            1123        1183      489951   83  Linux
        # 查看確認一下,存盤退出.
Command (m for help): w
The partition table has been altered!

再次嘗試放大
[root@seker ~]# resize2fs /dev/sda5 500M
resize2fs 1.39 (29-May-2006)
The containing partition (or device) is only 489951 (1k) blocks.
You requested a new size of 512000 blocks.

因為我們計算的是個粗略的值,畢竟存在誤差.故500M無法滿足,但這步能提示出能放大的最大數(shù):
is only 489951 (1k) blocks.

[root@seker ~]# resize2fs /dev/sda5 489951K
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/sda5 to 489951 (1k) blocks.
The filesystem on /dev/sda5 is now 489951 blocks long.

[root@seker ~]# 這次成功了.


[root@seker ~]# mount /dev/sda5 /mnt
[root@seker ~]# df -Th /dev/sda5
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda5     ext2    464M  142M  303M  32% /mnt
[root@seker ~]#  加載上來看看,已經(jīng)是464M了,和我們的計算基本吻合.看看已用用量142M是我們之前的數(shù)據(jù),還存在的. 只是類型上時ext2.

拿下來,再轉(zhuǎn)換成ext3吧

[root@seker ~]# umount /mnt/
[root@seker ~]# tune2fs -j /dev/sda5
tune2fs 1.39 (29-May-2006)
Creating journal inode: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@seker ~]# mount /dev/sda5 /mnt
[root@seker ~]# df -Th /dev/sda5
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda5     ext3    464M  151M  295M  34% /mnt
[root@seker ~]# ls /mnt/ |wc -l
75
[root@seker ~]# 原來的文件還在.

完美了.

做寫入測試:

[root@seker ~]# dd if=/dev/zero of=/mnt/seker_file_1 bs=1M count=20
20+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 0.124672 seconds, 168 MB/s
[root@seker ~]# dd if=/dev/zero of=/mnt/seker_file_2 bs=1M count=20
20+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 0.278653 seconds, 75.3 MB/s
[root@seker ~]# dd if=/dev/zero of=/mnt/seker_file_3 bs=1M count=20
20+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 0.373639 seconds, 56.1 MB/s
[root@seker ~]# df -Th /dev/sda5
文件系統(tǒng)      類型    容量  已用 可用 已用% 掛載點
/dev/sda5     ext3    464M  211M  235M  48% /mnt
[root@seker ~]#

寫了三個20M的文件進去.查看一下一切安好.


好久不來發(fā)帖了..歡迎一起研究.有什么問題 請多多指教..

[[i] 本帖最后由 Seker 于 2009-7-1 13:39 編輯 [/i]]

論壇徽章:
0
2 [報告]
發(fā)表于 2009-07-01 02:10 |只看該作者
另附上man resize2fs..
DESCRIPTION
       The resize2fs program will resize ext2 or ext3 file systems.   It  can  be
       used  to enlarge or shrink an unmounted file system located on device.  If
       the filesystem is mounted, it can be  used  to  expand  the  size  of  the
       mounted filesystem, assuming the kernel supports on-line resizing.  (As of
       this writing, the Linux 2.6 kernel supports on-line resize for filesystems
       mounted using ext3 only.).

       The size parameter specifies the requested new size of the filesystem.  If
       no units are specified, the units of  the  size  parameter  shall  be  the
       filesystem  blocksize  of  the filesystem.  Optionally, the size parameter
       may be suffixed by one of the following the units designators:  ’s’,  ’K’,
       ’M’,  or  ’G’,  for  512 byte sectors, kilobytes, megabytes, or gigabytes,
       respectively.  The size of the filesystem may never  be  larger  than  the
       size  of  the  partition.   If  size  parameter  is not specified, it will
       default to the size of the partition.

       The resize2fs program does not manipulate the size of partitions.  If  you
       wish  to enlarge a filesystem, you must first make sure you can expand the
       size of the underlying partition first.  This can be done  using  fdisk(8)
       by  deleting  the  partition and recreating it with a larger size or using
       lvextend(8), if you’re using the  logical  volume  manager  lvm(8).   When
       recreating  the  partition, make sure you create it with the same starting
       disk cylinder as before!  Otherwise, the resize operation  will  certainly
       not  work,  and  you  may  lose  your  entire  filesystem.   After running
       fdisk(8), run resize2fs to resize the ext2 filesystem to use  all  of  the
       space in the newly enlarged partition.

       If you wish to shrink an ext2 partition, first use resize2fs to shrink the
       size of filesystem.  Then you may use fdisk(8) to shrink the size  of  the
       partition.  When shrinking the size of the partition, make sure you do not
       make it smaller than the new size of the ext2 filesystem!


下面這段好像說是要內(nèi)核支持才能在線搞ext3的.不知道怎么弄.
       The resize2fs program will resize ext2 or ext3 file systems.   It  can  be
       used  to enlarge or shrink an unmounted file system located on device.  If
       the filesystem is mounted, it can be  used  to  expand  the  size  of  the
       mounted filesystem, assuming the kernel supports on-line resizing.  (As of
       this writing, the Linux 2.6 kernel supports on-line resize for filesystems
       mounted using ext3 only.).

整體來說 這部是關(guān)鍵,雖然我在上面收縮時并沒有去改結(jié)束的柱面位置,但也可以達到目的了.到達指定大小后就報警了.但不知道有什么副作用沒.
This can be done  using  fdisk(8) by  deleting  the  partition and recreating it with a larger size




測試了一下在線情況...沒辦法搞定,,,有高手知道怎么online做給指點一下..謝了
[root@stu33 ~]# resize2fs /dev/sda5 100M
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/sda5 is mounted on /mnt; on-line resizing required
On-line shrinking from 200780 to 102400 not supported.
[root@stu33 ~]# e2fsck -f /dev/sda5
e2fsck 1.39 (29-May-2006)
/dev/sda5 is mounted.  

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)? no

check aborted.
[root@stu33 ~]# tune2fs -O ^has_journal /dev/sda5
tune2fs 1.39 (29-May-2006)
The has_journal flag may only be cleared when the filesystem is
unmounted or mounted read-only.
[root@stu33 ~]#



OS版本

[root@stu33 ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.1 (Tikanga)

論壇徽章:
0
3 [報告]
發(fā)表于 2009-07-01 08:02 |只看該作者
矛盾;
因為收縮或放大的命令式resize2fs只針對ext2文件系統(tǒng)可用
The resize2fs program will resize ext2 or ext3 file systems.


The resize2fs program will resize ext2 or ext3 file systems.   It  can  be
       used  to enlarge or shrink an unmounted file system located on device.  If
       the filesystem is mounted, it can be  used  to  expand  the  size  of  the
       mounted filesystem, assuming the kernel supports on-line resizing.  (As of
       this writing, the Linux 2.6 kernel supports on-line resize for filesystems
       mounted using ext3 only.).
這部分說明了linux 2.6支持mount情況下的擴容

論壇徽章:
0
4 [報告]
發(fā)表于 2009-07-01 09:27 |只看該作者
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1122      522112+  82  Linux swap / Solaris
/dev/sda4            1123        2088     7759395    5  Extended
/dev/sda5            1123        1159      297171   83  Linux

1、sda1 = 100M 從柱面1到柱面13. 也就是說12個柱面是100M空間
2、給sda5 300M 使用柱面恰好是占用了 1159 - 1123 = 36 個.和我們前面計算的100M=12個柱面相吻合
那我問一下:
/dev/sda1   *           1          13
/dev/sda2              14        1057
/dev/sda3            1058        1122
/dev/sda4            1123        2088
/dev/sda5            1123        1159
中的第13柱面和第1123柱面去哪了?

論壇徽章:
0
5 [報告]
發(fā)表于 2009-07-01 09:31 |只看該作者
我覺得sda1應(yīng)該是13-1+1=13個柱面
sda5應(yīng)該說是1159-1123+1=37個柱面

論壇徽章:
0
6 [報告]
發(fā)表于 2009-07-01 13:31 |只看該作者
原帖由 marsaber 于 2009-7-1 09:27 發(fā)表
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1057     8385930   83  Linux
/dev/sda3            1058        1122      522112+  82  Linux swap /  ...




約值而已.

論壇徽章:
0
7 [報告]
發(fā)表于 2009-07-01 13:37 |只看該作者
原帖由 webyuhang 于 2009-7-1 08:02 發(fā)表
矛盾;
因為收縮或放大的命令式resize2fs只針對ext2文件系統(tǒng)可用
The resize2fs program will resize ext2 or ext3 file systems.


The resize2fs program will resize ext2 or ext3 file systems.   It  ...



恩,確實是支持ext3的.即使不轉(zhuǎn)化成EXT2的也可以做. 我修改一下.
后面的ext3 to ext2也可以省略.

課時后面的在線的 回頭我再去嘗試了.



謝謝...多此一舉了...呵呵.


后面說的在線 我沒實現(xiàn),修改后還是原來的大小,回頭再去嘗試一下.

[ 本帖最后由 Seker 于 2009-7-1 13:43 編輯 ]
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP