Ubuntu server kettajao suuruse muutmine: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Line 24: Line 24:
Ühendame vähendatava kettajao lahti
Ühendame vähendatava kettajao lahti
<pre>umount /dev/sda6</pre>
<pre>umount /dev/sda6</pre>
Kontrollime failisüsteemi üle
Samuti kettajao, mida suurendama hakkame
<pre>umount /dev/sda7</pre>
Kontrollime mõlemad failisüsteemid üle
<pre>
<pre>
root@popp:/usr# fsck -n /dev/sda6
root@popp:~# fsck -n /dev/sda6
fsck from util-linux-ng 2.17.2
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
e2fsck 1.41.12 (17-May-2010)
/dev/sda6: clean, 14897/61056 files, 61768/244224 blocks
/dev/sda6: clean, 7994/121920 files, 56869/487680 blocks
</pre>
</pre>
Muudame failisüsteemi ext2-ks
<pre>
root@popp:~# fsck -n /dev/sda7
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda7: clean, 4160/61056 files, 37871/243968 blocks
</pre>
Muudame failisüsteemid ext2-ks
<pre>
<pre>
root@popp:/usr# tune2fs -O ^has_journal /dev/sda6
root@popp:/usr# tune2fs -O ^has_journal /dev/sda6
tune2fs 1.41.12 (17-May-2010)
</pre>
<pre>
root@popp:/usr# tune2fs -O ^has_journal /dev/sda7
tune2fs 1.41.12 (17-May-2010)
tune2fs 1.41.12 (17-May-2010)
</pre>
</pre>
Kontrollime failisüsteemi:
Kontrollime failisüsteemi:
<pre>
<pre>
root@popp:/usr# e2fsck -f /dev/sda6
root@popp:~# e2fsck -f /dev/sda6
e2fsck 1.41.12 (17-May-2010)
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/sda6: 7994/121920 files (0.1% non-contiguous), 48668/487680 blocks
</pre>
<pre>
root@popp:~# e2fsck -f /dev/sda7
e2fsck 1.41.12 (17-May-2010)
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 1: Checking inodes, blocks, and sizes
Line 45: Line 67:
Pass 4: Checking reference counts
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Pass 5: Checking group summary information
/dev/sda6: 14897/61056 files (0.1% non-contiguous), 57667/244224 blocks
/dev/sda7: 4160/61056 files (0.0% non-contiguous), 33770/243968 blocks
</pre>
</pre>
Vähendame soovitud failisüsteemi vajaliku suuruseni. Siinjuures tuleb jälgida andmete säilimise pärast, et see ei oleks väiksem, kui viimati kasutuses olnud maht. Antud juhul mitte väiksem, kui 227M ning hetkel vähendame 300MB-ni.  
Vähendame soovitud failisüsteemi vajaliku suuruseni. Siinjuures tuleb jälgida andmete säilimise pärast, et see ei oleks väiksem, kui viimati kasutuses olnud maht. Antud juhul mitte väiksem, kui 227M ning hetkel vähendame 300MB-ni.  
<pre>
<pre>
root@popp:/usr# resize2fs /dev/sda6 300M
root@popp:~# resize2fs /dev/sda6 300M
resize2fs 1.41.12 (17-May-2010)
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sda6 to 76800 (4k) blocks.
Resizing the filesystem on /dev/sda6 to 76800 (4k) blocks.

Revision as of 23:03, 7 December 2010

Sissejuhatus

Nõuded süsteemile

Antud lahendus on testitud Ubuntu Server 10.10 peal. Tegemist on kolme ext3 failisüsteemiga, millest ühte suurendame ning teist vähendame nii, et nendel olevad andmed säiliksid.

Ettevalmistus

Esmalt tuleb end logida juurkasutajaks

sudo -i

Uurime millised partitsioonid hetkel olemas on

root@popp:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             4.3G  2.2G  1.9G  55% /
none                  243M  232K  243M   1% /dev
none                  249M  224K  249M   1% /dev/shm
none                  249M   92K  249M   1% /var/run
none                  249M     0  249M   0% /var/lock
/dev/sda6             1.9G  193M  1.6G  11% /home/first
/dev/sda7             938M  133M  758M  15% /home/second

Kettaruumi vähendamine

Ühendame vähendatava kettajao lahti

umount /dev/sda6

Samuti kettajao, mida suurendama hakkame

umount /dev/sda7

Kontrollime mõlemad failisüsteemid üle

root@popp:~# fsck -n /dev/sda6
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda6: clean, 7994/121920 files, 56869/487680 blocks
root@popp:~# fsck -n /dev/sda7
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda7: clean, 4160/61056 files, 37871/243968 blocks

Muudame failisüsteemid ext2-ks

root@popp:/usr# tune2fs -O ^has_journal /dev/sda6
tune2fs 1.41.12 (17-May-2010)
root@popp:/usr# tune2fs -O ^has_journal /dev/sda7
tune2fs 1.41.12 (17-May-2010)

Kontrollime failisüsteemi:

root@popp:~# e2fsck -f /dev/sda6
e2fsck 1.41.12 (17-May-2010)
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/sda6: 7994/121920 files (0.1% non-contiguous), 48668/487680 blocks
root@popp:~# e2fsck -f /dev/sda7
e2fsck 1.41.12 (17-May-2010)
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/sda7: 4160/61056 files (0.0% non-contiguous), 33770/243968 blocks

Vähendame soovitud failisüsteemi vajaliku suuruseni. Siinjuures tuleb jälgida andmete säilimise pärast, et see ei oleks väiksem, kui viimati kasutuses olnud maht. Antud juhul mitte väiksem, kui 227M ning hetkel vähendame 300MB-ni.

root@popp:~# resize2fs /dev/sda6 300M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sda6 to 76800 (4k) blocks.
The filesystem on /dev/sda6 is now 76800 blocks long.

Järgmiseks kustutame partitsiooni, ning loome uue ning väiksema. Antud juhul tuleb tähele panna uue partitsiooni loomisel last cylinder väärtust. Selle saame korrutades failisüsteemi plokkide arvu ja plokisuuruse, mille saime failisüsteemi vähendamise väljundist, omavahel ning lisame sellele umbes 5% lisaks, et olla kindel et uus partitsioon oleks piisavalt suur failisüsteemi jaoks. Ehk asendades arvud valemisse: 76800*4*1.05=322560(KB)

root@popp:/usr# fdisk /dev/sda

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): d
Partition number (1-6): 6

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (801-923, default 801): 
Using default value 801
Last cylinder, +cylinders or +size{K,M,G} (801-922, default 922): +322560K

Command (m for help): w
The 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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

Nagu hoiatusest selgus, peame masina taaskäivitama:

reboot now