butonel: Mihai Stancu | februarie 10th, 2015
0FreeBSD – miniTutorial Partitii UFS
Recent am facut o modificare pe un server pe care aveam FreeBSD 10 si anume am introdus un HDD nou nepartitionat
pe care doream sa-l partitionez folosind UFS nu ZFS.
Ce este UFS? O discutie luna, poate un post viitor;
Ce este ZFS? O discutie de 3 ori mai lunga, dar sigur voi scrie si despre asta!
Revenind la necesitatea mea, dupa cum spuneam mai devreme, in urma cu ceva timp am facut o singura partitie de 20GB pe un hdd proaspat introdus intr-un server BSD, prin urmare mai aveam spatiu nefolosit din acel HDD;
A venit momentul in care sa fiu nevoit sa ma folosesc si de spatiul nefolosit de pe HDD-ul partitionat cu UFS:
Ce avem?
Pasul 1. Butoneala pentru informare
Q: Ce HDD-uri sunt in sistem? Cum sunt ele identificate de BSD?
# camcontrol devlist -v
scbus0 on ahcich0 bus 0:
at scbus0 target 0 lun 0 (ada0,pass0)
<> at scbus0 target -1 lun -1 ()
scbus1 on ahcich1 bus 0:
at scbus1 target 0 lun 0 (ada1,pass1)
<> at scbus1 target -1 lun -1 ()
scbus2 on ahcich2 bus 0:
at scbus2 target 0 lun 0 (ada2,pass2)
<> at scbus2 target -1 lun -1 ()
scbus3 on ahcich3 bus 0:
at scbus3 target 0 lun 0 (ada3,pass3)
<> at scbus3 target -1 lun -1 ()
scbus4 on ahcich4 bus 0:
at scbus4 target 0 lun 0 (cd0,pass4)
<> at scbus4 target -1 lun -1 ()
scbus5 on ahcich5 bus 0:
<> at scbus5 target -1 lun -1 ()
scbus-1 on xpt0 bus 0:
<> at scbus-1 target -1 lun -1 (xpt0)
# dmesg | grep ada
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: ATA-8 SATA 2.x device
ada0: Serial Number 6VM1PW9R
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad4
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: ATA-9 SATA 3.x device
ada1: Serial Number CVDA401503RV2403GN
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada1: Command Queueing enabled
ada1: 228936MB (468862128 512 byte sectors: 16H 63S/T 16383C)
ada1: quirks=0x1
ada1: Previously was known as ad6
ada2 at ahcich2 bus 0 scbus2 target 0 lun 0
ada2: ATA-9 SATA 3.x device
ada2: Serial Number CVDA401603932403GN
ada2: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada2: Command Queueing enabled
ada2: 228936MB (468862128 512 byte sectors: 16H 63S/T 16383C)
ada2: quirks=0x1
ada2: Previously was known as ad8
ada3 at ahcich3 bus 0 scbus3 target 0 lun 0
ada3: ATA-7 SATA 2.x device
ada3: Serial Number WD-WCANM1149586
ada3: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
ada3: 152627MB (312581808 512 byte sectors: 16H 63S/T 16383C)
ada3: Previously was known as ad10
Identificam HDD-ul pe care il vizam spre modificare, ada3 (WDC WD1600JS-60MHB1);
Q: Cum este partitionat HDD-ul ? Ce tipuri de partiti sunt? Ce mai putem afla despre ele?
# gpart show ada3
=> 34 312581741 ada3 GPT (149G)
34 41943040 1 freebsd-ufs (20G)
41943074 270638701 - free - (129G)
Partitia 1, tipul freebsd-ufs, 20GB, incepe de la sectorul 1 si se termina la sectorul 41943040
Spatiul nepartitionat/nefolosit, 129GB, de la sectorul 41943071 la 270638701
# gpart list ada3
Geom name: ada3
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 312581774
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada3p1
Mediasize: 21474836480 (20G)
Sectorsize: 512
Stripesize: 0
Stripeoffset: 17408
Mode: r1w1e1
rawuuid: bf29f91a-990c-11e4-a025-001b219a1ec9
rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
label: data3
length: 21474836480
offset: 17408
type: freebsd-ufs
index: 1
end: 41943073
start: 34
Consumers:
1. Name: ada3
Mediasize: 160041885696 (149G)
Sectorsize: 512
Mode: r1w1e2
Q: Ce partitii sunt montate in sistem si cat spatiu este utilizat?
# df -h
Filesystem Size Used Avail Capacity Mounted on
zroot/ROOT/default 450G 17G 433G 4% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/ada3p1 19G 3.8G 14G 21% /lex
zroot/tmp 433G 464K 433G 0% /tmp
zroot/usr/home 433G 144K 433G 0% /usr/home
zroot/usr/ports 435G 1.8G 433G 0% /usr/ports
zroot/usr/src 434G 545M 433G 0% /usr/src
zroot/var 434G 190M 433G 0% /var
zroot/var/crash 433G 148K 433G 0% /var/crash
zroot/var/log 433G 4.7M 433G 0% /var/log
zroot/var/mail 433G 336K 433G 0% /var/mail
zroot/var/tmp 433G 152K 433G 0% /var/tmp
winmentmirror 190G 29G 161G 15% /winmentmirror
Dupa ce observam ca partitia 1 din ada3, adica ada3p1 este montata in /lex , ne gandim sa fim foarte atenti cum manevram hdd-ul sistemul de partitionare pentru a nu ajunge in situatia in care sa pierdem date!
Pasul 2. Crearea partitiei in BSD
Mai intai trebuie sa introducem in schema de partitionare GPT noua partitie
# gpart add -t freebsd-ufs ada3
ada3p2 added
Verificam daca partitia a fost adaugata
# gpart list ada3
Geom name: ada3
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 312581774
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada3p1
Mediasize: 21474836480 (20G)
Sectorsize: 512
Stripesize: 0
Stripeoffset: 17408
Mode: r1w1e1
rawuuid: bf29f91a-990c-11e4-a025-001b219a1ec9
rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
label: data3
length: 21474836480
offset: 17408
type: freebsd-ufs
index: 1
end: 41943073
start: 34
2. Name: ada3p2
Mediasize: 138567014912 (129G)
Sectorsize: 512
Stripesize: 0
Stripeoffset: 17408
Mode: r0w0e0
rawuuid: bc46bf5a-b0a0-11e4-99ec-001b219a1ec9
rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
label: (null)
length: 138567014912
offset: 21474853888
type: freebsd-ufs
index: 2
end: 312581774
start: 41943074
Consumers:
1. Name: ada3
Mediasize: 160041885696 (149G)
Sectorsize: 512
Mode: r1w1e2
Acum generam partitia folosind sistemul de fisiere UFS
# newfs -U /dev/ada3p2
/dev/ada3p2: 132147.8MB (270638696 sectors) block size 32768, fragment size 4096
using 212 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
with soft updates
super-block backups (for fsck -b #) at:
192, 1282432, 2564672, [...text similar inutil...], 257730432,
259012672, 260294912, 261577152, 262859392, 264141632, 265423872, 266706112, 267988352, 269270592, 270552832
Pasul 3. Montarea partitiei de tip UFS (freebsd-ufs)
Cream un director nou unde vrem sa montam partitia
# mkdir /oldserver
Montam partitia in directorul creat anterior
# mount -t ufs /dev/ada3p2 /oldserver
Verificam daca partitia este montat si spatiul este recunoscut adecvat
# df -h
Filesystem Size Used Avail Capacity Mounted on
zroot/ROOT/default 450G 17G 433G 4% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/ada3p1 19G 3.8G 14G 21% /lex
zroot/tmp 433G 464K 433G 0% /tmp
zroot/usr/home 433G 144K 433G 0% /usr/home
zroot/usr/ports 435G 1.8G 433G 0% /usr/ports
zroot/usr/src 434G 545M 433G 0% /usr/src
zroot/var 434G 190M 433G 0% /var
zroot/var/crash 433G 148K 433G 0% /var/crash
zroot/var/log 433G 4.7M 433G 0% /var/log
zroot/var/mail 433G 336K 433G 0% /var/mail
zroot/var/tmp 433G 152K 433G 0% /var/tmp
winmentmirror 190G 29G 161G 15% /winmentmirror
/dev/ada3p2 125G 8.0K 115G 0% /oldserver
Pasul 4. Finalizare. Modificari permanente in fisierul /etc/fstab
Editati fisierul /etc/fstab si adaugati in el linia care va monta automat la start-up partitia
/dev/ada3p2 /oldserver ufs rw 2 2
Era sa uit de pasul asta…
Spor la treaba si aveti grija! Nu va jucati cu partitiile, nu va jucati cu HDD-urile in BSD daca nu sunteti sigur ca intelegeti ceea ce faceti!
Va multumesc pentru intelegere!