可能做法:

一、直接改目錄,但因檔案格式不同擔心移過去後會有其他問題。

二、在隨身碟上建立虛擬檔案,將虛擬檔案格式化成ext4,這樣就不會有擔心的問題。

三、其他:暫時還沒有想到

所以就執行第二點的方式。

 

一、建立虛擬檔案

 

Create a New Image to Hold Virtual Drive Volume

There are number of ways you can do this, but the most easiest way is using the following dd command. In this example, we will be creating a VHD volume of size 1GB image.

$ sudo dd if=/dev/zero of=VHD.img bs=1M count=1200

Where:

if=/dev/zero: input file to provide a character stream for initializing data storage
of=VHD.img: image file to be created as storage volume
bs=1M: read and write up to 1M at a time
count=1200: copy only 1200M (1GB) input blocks
 

格式化及掛載

$ sudo mkfs -t ext4 /media/VHD.img
$ sudo mkdir /mnt/VHD/
$ sudo mount -t auto -o loop /media/VHD.img /mnt/VHD/
$ df -hT

Note: The VHD filesystem will only remain mounted until the next reboot, to mount it at system boot, add this entry in the /etc/fstab file.

/media/VHD.img /mnt/VHD/ ext4 defaults 0 0

 

Removing Virtual Drive Volume

$ sudo umount /mnt/VHD/
$ sudo rm /media/VHD.img
 

二、移動mariadb資料庫及設定

 

掛載碟區及停止資料庫運作

mount -t xfs /dev/sdb5 /media/hd2
service mysql stop
 

移動資料庫

Afterthat, I copied the entire db to newly mounted hard disk:

cp -rv /var/lib/mysql /media/hd2

It will take a while if you have huge databases.

 

改變目錄使用者

Then, change the ownership of the dir to user and group of mysql:

chown -R mysql:mysql /media/hd2/mysql
 

改變設定

You need to change the mysql config file in /etc/mysql/mariadb.conf.d/50-server.cnf to point to the dir:

[mysqld]
user = mysql
datadir = /media/hd2/mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
 

重新啟動資料庫

Now you can restart mysql db:

service mysql start
 

三、ln 使用法

src: https://www.ltsplus.com/linux/ln-create-link-command

ln -s /var/www/ /var/public_html

/var/www/ 為要連接的目標

/var/public_html 為要建立的檔案

arrow
arrow
    文章標籤
    mariadb cubieboard
    全站熱搜

    理群 發表在 痞客邦 留言(0) 人氣()