Thursday, August 9, 2012

Cài Arch linux offline

Hưởng ứng bài viết moving System của anh Kỳ Anh, sau một đêm hí hoáy cuối cùng mình cũng cài xong Arch theo một cách cực kì crazy :-))  

1.Ý tưởng ban đầu:

-Phiên bản Arch mới 15/7 có nhiều thay đổi, quan trọng nhát là loại bỏ hệ thống AFI (Arch Flamework Installation ). Điều này có nghĩa là việc cài đặt Arch sẽ giống với Gentoo và phải có network.

-  Việc bạn boot vào bằng iso file tức là bạn đã có một base-system. Vậy tại sao không dùng chính base-system đó mà xây dựng lên ?  

2.Hiện thực ý tưởng :

-Sau khi bạn boot vào bằng iso file, sẽ cần thực hiện các bước sau:

+ Phân chia lại lãnh thổ cho từng vùng: /, /home, /boot và swap:   -fdisk /dev/sda: nhấn m để xem menu hướng dẫn.

-Tôi thực hiện phân vùng theo thứ tự sau cho dễ nhớ:

.Boot -> Root -> swap ->Home (ext2 - > ext4 ->swap -> ext4)

+ Mount phân vùng Root: mount /dev/sda2 /mnt

+ Tai đây ta sẽ tiến hành copy toàn bộ image của hệ thống hiện tại vào /mnt:

cp -R /usr /mnt cp -R /bin /mnt

cp -R /sbin /mnt cp -R /etc /mnt

cd /mnt  &&  mkdir dev mnt

proc run  srv  tmp var media  opt   root sys home boot

ln -s usr/lib lib

+vấn đề tiếp theo là cp file vmlinux và tạo initrmfs.img:

mount /dev/sda1 /mnt/boot

Tiến hành copy file vmlinux:

cp /usr/src/3.4.4-3-ARCH/vmlinux /boot

Tiến hành tạo file initramfs.img

mkinitcpio -c /etc/mkinitcpio-custom.conf -g /boot/initramfs.img

+ Copy grub-legacy:

cp -a /usr/lib/grub/i386-pc/* /boot/grub

+ Chroot vào hệ thống mới: chroot /mnt /bin/bash

mount -t proc none /mnt/proc mount --rbind /dev /mnt/dev grub grub>root (hd0,0) grub>setup (hd0) grub>quit

+ Chỉnh sửa lại file menu.lst cho phù hợp với các phân vùng của bạn.

+ Chỉnh sửa file /etc/fstab: Bạn chỉnh sửa lại fstab cho phù hợp với các phân vùng của bạn:

devpts                 /dev/pts      devpts    defaults            0      0 shm                    /dev/shm      tmpfs     nodev,nosuid        0      0 tmpfs               /tmp         tmpfs     nodev,nosuid /dev/sdax           /Y                 Z           defaults             0       1   với x là số của phân vùng Y là mount point và Z là filesystem.   +Chỉnh sửa file /etc/inittab để tránh việc autologin vào root trên tty1: xóa đoạn -a root trong file /etc/inittab   +Đặt lại passwd root: passwd root   reboot   With Linux, we are owner and lord

Sunday, August 5, 2012

Cấu hình /etc/fstab tự mount khi khởi động (Arch Linux)

Đây là file /etc/fstab của mình:
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs nodev,nosuid 0 0
# UUID=18f4379c-4862-4897-9645-5d24440b1429
/dev/sda3 / ext4 rw,relatime,data=ordered 0 1

# UUID=c6956948-4ca1-4bef-a777-1ac6d9e1f0ce
/dev/sda1 /boot ext4 rw,relatime,data=ordered 0 2

# UUID=0ea7ea96-3734-47fc-9304-6f2a34a19be4
none swap defaults 0 0
# <file system> <dir> <type> <options> <dump> <pass>
/dev/sda5 /home/archie/DATA ntfs-3g auto,noatime,user 0 0
/dev/sda6 /home/archie/MEDIA ntfs-3g auto,noatime,user 0 0

Trước tiên ta cần cài đặt gói ntfs-3g qua lênh: 
# pacman -Ss ntfs-3g

Để xem danh sách các partition trên ổ cứng:
[root@haidanghost archie]# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 8EDC5E5F-16C3-4B7E-A088-4EA094319215
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 74964432 sectors (35.7 GiB)

Number Start (sector) End (sector) Size Code Name
1 40 512039 250.0 MiB 8300 Linux filesystem
2 512040 2609191 1024.0 MiB 8200 Linux swap
3 2609192 104856324 48.8 GiB 8300 Linux filesystem
5 104856325 524297339 200.0 GiB 0700 Microsoft basic data
6 524297406 901808774 180.0 GiB 0700 Microsoft basic data

Còn đây là phần giải thích cấu trúc của file /etc/fstab (trích: https://wiki.archlinux.org/index.php/Fstab):
The /etc/fstab file contains the following fields separated by a space or tab:
<file system> <dir> <type> <options> <dump> <pass>


  • <file system> - the partition or storage device to be mounted.

  • <dir> - the mountpoint where <file system> is mounted to.

  • <type> - the file system type of the partition or storage device to be mounted. Many different file systems are supported: ext2, ext3, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swapand auto. The auto type lets the mount command guess what type of file system is used. This is useful for removable devices such as cdroms and dvds.

  • <options> - the options of the filesystem to be used. Note that some options are filesystem specific. Some of the most common options are:



  • auto - Mount automatically at boot, or when the command mount -a is issued.

  • noauto - Mount only when you tell it to.

  • exec - Allow execution of binaries on the filesystem.

  • noexec - Disallow execution of binaries on the filesystem.

  • ro - Mount the filesystem read-only.

  • rw - Mount the filesystem read-write.

  • user - Allow any user to mount the filesystem. This automatically implies noexec, nosuid, nodev, unless overridden.

  • users - Allow any user in the users group to mount the filesystem.

  • nouser - Allow only root to mount the filesystem.

  • owner - Allow the owner of device to mount.

  • sync - I/O should be done synchronously.

  • async - I/O should be done asynchronously.

  • dev - Interpret block special devices on the filesystem.

  • nodev - Don't interpret block special devices on the filesystem.

  • suid - Allow the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.

  • nosuid - Block the operation of suid, and sgid bits.

  • noatime - Don't update inode access times on the filesystem. Can help performance (see atime options).

  • nodiratime - Do not update directory inode access times on the filesystem. Can help performance (see atime options).

  • relatime - Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.) Can help performance (see atime options).

  • flush - The vfat option to flush data more often, thus making copy dialogs or progress bars to stay up until all data is written.

  • defaults - the default mount options for the filesystem to be used. The default options for ext3 are: rw, suid, dev, exec, auto, nouser, async.



  • <dump> - used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the <dump> entry.


  • <pass> - used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 - all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.

Thursday, August 2, 2012

Chia sẽ internet qua cáp mạng (thông qua wireless)

MÔ HÌNH KẾT NỐI



1. Thiết lập cấu hình trên máy laptop (đang kết nối internet wireless)

- Chọn card mạng mà được kết nối trực tiếp với Internet (card mạng wireless): Start -> Setting -> Networks Connection (hoặc chuột phải lên My Network Places chọn Properties)


Click phải chuột lên card mạng wireless và chọn Properties. Chọn tab Advanced, sau đó chọn vào 2 dấu check


- Phần Home networking connection thì chọn chọn card mạng thứ 2 muốn chia sẽ kết nối internet (hay nói cách khác là card mà không ra ngoài Internet trực tiếp, ở đây do trên máy demo có hơn 2 card mạng  LAN nên phải chọn mục này).
- Khi đó card mạng share sẽ có hình bàn tay share ra.


- Kiểm tra IP: Vào Start -> Run: gõ cmd rồi chọn Run (hoặc Enter). Sau đó gõ ipconfig rồi xem kỹ phần ip của card mạng được share (card mạng chọn trong phần Home networking connection)


Chú ý: IP là 192.168.0.1, phần này quan trọng


2. Thiết lập cấu hình cho máy cần kết nối Internet.


- Chọn card mạng: Start -> Setting -> Networks Connection (hoặc chuột phải lên My Network Places chọn Properties)
- Chọn phần Internet Protocol (TCP/IP) rồi đặt IP như hình vẽ


- IP address
: đặt địa chỉ ip trùng với lớp mạng 192.168.0.1. Trên hình đặt là 192.168.0.2, ngoài ra bạn có thể đặt số khác, nhưng phải bắt đầu là 192.168.0.X (X có thể có thể chọn từ 2 -> 254)
- Subnet mask: 255.255.255.0
- Default gateway: bắt buộc như ở trên (IP của bước 2 được tô đậm)
- DNS Server: như trên.
- Với máy laptop hay máy để bàn muốn share cho nhiều máy thì phải có thiết bị Switch để nối các máy tính với nhau, lúc này làm tương tự, nhưng card mạng của máy share Internet không nối trực tiếp với máy nào, mà nói vào Switch.
Nguồn: vn-zoom