Thursday, December 26, 2019

Adding Hard Drive or External Storage to Mikrotik

Internal storage of Mikrotik is not enough if you have user manager running in mikrotik and it has big database of hotspot user. To solve the problem you need to add external storage to Mikrotik. If your Mikrotik has usb port on it then you can attach flashdrive or ssd drive using connector like OTG Micro Usb or others, it depends on your Mikrotik specification .
You can format the drive in windows to fat32 file system or in Mikrotik to ext3/fat32 file system. But it is recommended to use ext3 than fat32 file system. After that, attach the drive to mikrotik, then login to mikrotik using winbox :

1. Check if mikrotik sees the attached drive or not :

disk print
# NAME        LABEL         TYPE    DISK    FREE       SIZE
0 disk1       NO NAME       fat32     00       6.6GiB     7.2GiB

As you can see mikrotik sees the drive as disk1.

2. Check if mikrotik has mounted the drive or not :

file print
 # NAME     TYPE        SIZE       CREATION-TIME
 0 disk1        disk                          apr/20/2015 13:44:11
 1 skins        directory                  jan/01/1970 03:00:01
 2 pub          directory                  feb/04/1970 21:31:40 

Mikrotik also mounted the drive as disk1.

3. If you haven't formatted the drive to well-known file system, you can format it in mikrotik. First you need to unmount the drive :

disk eject-drive 0

0 is the id number of the drive after you do disk print .

4. Then you can format the drive using the following command :

disk format-drive 0 file-system=ext3 label=usb-flash

5. If you want to use the drive as cache for web-proxy, use the following command :

ip proxy set cache-path=disk1/cache-n-db/proxy/

A directory and sub-directory will be created automatically. Check if the directories are created or not :

file print
 # NAME                                 TYPE                      SIZE              CREATION-TIME
 0 skins                                     directory                                       mar/02/2015 18:56:23
 1 sys-note.txt                         .txt file                        23               jul/03/2015 11:40:48
 2 disk1                                   disk                                               jul/03/2015 11:35:05
 3 disk1/lost+found                directory                                       jul/03/2015 11:34:56
 4 disk1/cache-n-db               directory                                       jul/03/2015 11:41:54
 4 disk1/cache-n-db/proxy     web-proxy store                           jul/03/2015 11:42:09

6. If you want to use the drive for user manager database path , use the following command :

tool user-manager database set db-path=disk1/cache-n-db/user-manager/

A directory and sub-directory also will be created automatically. Check if the directories are created or not :

file print where name~"user-manager"
 #  NAME                                                           TYPE              SIZE          CREATION-TIME     
 0 disk1/cache-n-db/user-manager/                 directory                              jul/03/2015 12:17:38
 1 disk1/cache-n-db/user-manager/sqldb           file               367.0KiB      jul/03/2015 12:17:38
 2 disk1/cache-n-db/user-manager/logsqldb     file               29.0KiB        jul/03/2015 11:00:42

7. If you want to move the database of user manager that has been installed in internal/system drive mikrotik to external drive, use the following command :

- First create backup of the user manager database :
tool user-manager database save name=/disk1/UMBackup

- Change or set the user-man database path :
tool user-manager database set db-path=disk1/cache-n-db/user-manager/

- Restore the user-man database backup using the backup file we created earlier :
tool user-manager database load name=/disk1/UMBackup

8. If you want to move the Logging on disk to external drive, make sure you have created directory to store the log files. To do that, create new folder in windows and rename it to log, then open file section in winbox then drag the log folder into winbox - file and place it in/under disk1 directory. Then set/change the log path file using the following command :

system logging action set disk disk-file-name=/disk1/log/syslog

Check if  the log file has been created or not using the following command :

file print where name~"disk1/log" 
 # NAME                                 TYPE          SIZE          CREATION-TIME     
 0 disk1/log                            directory                        jul/03/2015 12:44:09
 1 disk1/log/syslog.0.txt         .txt file         160          jul/03/2015 12:44:11

9. You can set schedule for backup database automatically. To do so, make a new schedule and paste this commands into On Event box :

tool user-manager database save name=/disk1/UMBackup overwrite=yes

Source : https://wiki.mikrotik.com/wiki/Manual:System/Disks 

No comments:

Post a Comment