==== save image ======
robert@robert-desktop ~/Test $ sudo ntfsclone --save-image --output clonentfs.img /dev/sdb2
ntfsclone v2.0.0 (libntfs 10:0:0)
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 8044322816 bytes (8045 MB)
Current device size: 8044323840 bytes (8045 MB)
Scanning volume ...
100.00 percent completed
Accounting clusters ...
Space in use : 864 MB (10.7%)
Saving NTFS to image ...
100.00 percent completed
Syncing ...
====== restore =========
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
Ntfsclone image version: 10.0
Cluster size : 4096 bytes
Image volume size : 8044322816 bytes (8045 MB)
Image device size : 8044323840 bytes
Space in use : 864 MB (10.7%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
100.00 percent completed
Syncing ...
==== Error if you restore a smaller partition =====
robert@robert-desktop ~/Test $ sudo ntfsclone --restore-image --overwrite /dev/sdb2 clonentfs.img
ntfsclone v2.0.0 (libntfs 10:0:0)
ERROR: Output device is too small (3708230144) to fit the NTFS image (8044323328).
2009年10月26日 星期一
2009年10月20日 星期二
安裝與設定 apache 2.2 with WebDAV and AuthType=Digest
如果你要設定把Apache的AuthType設為Digest,要注意:
1. 你的Apache 版本,不同版本設定很不一樣: http://httpd.apache.org/docs/ 查mod_auth_digest
2. 非常tricky的地方(文件沒提到):
=====
安裝:
sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 apache2-utils
設定
1) 啟用WebDAV
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
sudo a2enmod auth_digest
2) 建立 WebDAV 使用者 (舉例:使用者 robertDAV)
sudo htdigest -c /etc/apache2/.digestpwd.dav /davshared/ robertdav
(Basic認證才用 htpasswd )
1. 你的Apache 版本,不同版本設定很不一樣: http://httpd.apache.org/docs/ 查mod_auth_digest
2. 非常tricky的地方(文件沒提到):
AuthName 要設得跟
realm
一樣
,不然會總是認證失敗!=====
安裝:
sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 apache2-utils
設定
1) 啟用WebDAV
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
sudo a2enmod auth_digest
2) 建立 WebDAV 使用者 (舉例:使用者 robertDAV)
sudo htdigest -c /etc/apache2/.digestpwd.dav /davshared/ robertdav
(Basic認證才用 htpasswd )
(如果有兩組以上user要設定,可能要手動填第二行喔!不然第二次使用htdigest會把第一組的資料"切掉")
3) 建立共享的 WebDAV 目錄
sudo mkdir /var/www/davshared/
sudo chown www-data:www-data /var/www/davshared/
4) 設定apache config 關於 WebDAV 目錄位置、權限等
vim /etc/apache2/sites-available/default
插入:
(請自動把以下的( )換成< >,因打< >在此秀不出來)
5) 重啟 apache
sudo /etc/init.d/apache2 restart
========================
Reference:
Setting up a WebDAV server
http://www.linuxquestions.org/questions/linux-server-73/digest-authentication-not-working-on-default-apache-installation-on-slackware-12.1-730785/
http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html
http://samiux.wordpress.com/2009/06/27/howto-webdav-on-ubuntu-9-04-server/
3) 建立共享的 WebDAV 目錄
sudo mkdir /var/www/davshared/
sudo chown www-data:www-data /var/www/davshared/
4) 設定apache config 關於 WebDAV 目錄位置、權限等
vim /etc/apache2/sites-available/default
插入:
(請自動把以下的( )換成< >,因打< >在此秀不出來)
Alias /davshared/ "/var/www/davshared/" (Directory "/var/www/davshared/") Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all #Allow from 192.168.0.0/255.0.0.0 ::1/128 (/Directory) (Location /davshared/) DAV On AuthName "/davshared/" #AuthType Basic #AuthUserFile /etc/apache2/.passwd.dav AuthType Digest AuthDigestProvider file AuthDigestDomain /davshared/ AuthUserFile /etc/apache2/.digestpwd.dav DavMinTimeout 600 #(LimitExcept GET PUT HEAD OPTIONS POST) (LimitExcept GET HEAD OPTIONS) Require valid-user (/LimitExcept) (/Location)
5) 重啟 apache
sudo /etc/init.d/apache2 restart
========================
Reference:
Setting up a WebDAV server
http://www.linuxquestions.org/questions/linux-server-73/digest-authentication-not-working-on-default-apache-installation-on-slackware-12.1-730785/
http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html
http://samiux.wordpress.com/2009/06/27/howto-webdav-on-ubuntu-9-04-server/
2009年10月18日 星期日
認識 initrd 與 initramfs
查wiki的initrd有很好的說明
這裡提供最簡易的認知
Linux系統開機時,除了載入kernel,還需掛載根檔案系統(rootfs),
由於根檔案系統並不一定能很容易的被掛載,(例如rootfs不位在本機硬碟,需要使用其它工具才能從遠端掛載它;又例如你的rootfs在特殊的儲存裝置,需要先載入它的driver才能正常使用)。
為了提供足夠掛載真正 rootfs 能力,所以設計成兩階段掛載rootfs,先掛載容易取得的 initrd檔為rootfs,有了足夠的能力,再掛載真正的rootfs,這樣的設計就很有彈性。
當然initrd檔要放在系統很容易就能存取到的地方,例如kernel有支援的硬碟中的一個檔案。
initrd檔案有兩種:
1. (old) Ram disk image : (optionally gzip-compressed) file system image (例如一個 ext2 file system 的壓縮檔)
2. (new) Initramfs image: gzip-compressed cpio archive (直接將開機所需檔丟給 cpio,再經 gzip 壓縮)
kernel能自行判斷是哪一種 initrd 檔,成功解壓縮形成在 ram 中的 rootfs。如果是 Ram disk image,就會把原本的 file system (如ext2) 還原成 ram disk;如果是 initramfs image,則會使用它cpio中包含的檔案形成 tmpfs file system(或是較舊的 ramfs file system)
雖然也是在 ram 中運作,但 tmpfs 並不是 ram disk,ram disk 指的是把一般的 disk file system 放到 ram 中運作,而 tmpfs就是設計在ram中運作,並不是 disk file system,也比它有效率。
My note on creating initramfs:
To extract initramfs:
gunzip < /boot/initrd.img-2.6.28-11-generic | cpio -i -d -H newc --no-absolute-filenames
To create initramfs:
cd myinitrd/
find . | cpio -o -H newc | gzip > ../myinitrd.gz
Note 1: Makesure all files in myinitrd/ are belong to root (chown -R 0:0 *). Otherwise, init script may fail to mount proc and show you "permission denied (are you root )" errors.
Note 2: use gzip -9 ... may lead to kernel panic "invalid compressed format" when booting !! Guess it's because some vmlinuz doesn't support that compression level.
Reference:
深入理解 Linux 2.6 的 initramfs 機制 (上)
Introducing initramfs, a new model for initial RAM disks
how to create an initramfs image
https://www.kernel.org/doc/Documentation/initrd.txt
https://www.kernel.org/doc/Documentation/initrd.txt
2009年10月1日 星期四
Sed : remove empty lines, remove beginning spaces, tabs
Remove empty lines:
cat file|sed /^$/d
Remove beginning spaces:
cat file|sed s/^\ *//g
Remove beginning tabs:
cat file|sed s/^\\t*/d
(Remove=Replace with nothing)
cat file|sed /^$/d
Remove beginning spaces:
cat file|sed s/^\ *//g
Remove beginning tabs:
cat file|sed s/^\\t*/d
(Remove=Replace with nothing)
訂閱:
文章 (Atom)